<?php
/**
 * $Id: router.php 13 2009-01-11 15:22:40Z chaoskaizer $
 * WP-iStalker Chrome Min 
 * URL content handler
 * 
 * @package WordPress
 * @subpackage wp-istalker-chrome-min
 * 
 * @author	Avice (ChaosKaizer) De'vereux <ck@animepaper.net>
 * @license	http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License v2 
 * @filesource	$URL: http://wp-istalker-min.googlecode.com/svn/branches/WP%202.7/0.1/router.php $
 * @since	0.1
 */

if (isset($_SERVER['REDIRECT_QUERY_STRING'])){

/**
 * Check Client User agent simple browser detection
 * {@see wp-includes/var.php}
 * 
 * @param bool $display set to true to print out user agent name
 * @since 0.1
 */
function wpi_is_browser($display = false){	
	$browser = false;	
	foreach(explode(',','lynx,gecko,winIE,macIE,opera,NS4,safari,chrome,iphone') as $ua){
		if ($GLOBALS['is_'.$ua]){
			$browser = $ua;	
			break;	
		}				
	}
	
	if ($display): echo $browser; else: return $browser; endif; 
}
	
define('KAIZEKU',1);
define('DIRSEP',DIRECTORY_SEPARATOR);
define('RT',dirname(__FILE__).DIRSEP);	

// taken from WordPress core "Simple browser detection" wp-includes/vars.php 
$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;

if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) {
	$is_lynx = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
	$is_chrome = true;
} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false ) {
	$is_safari = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) {
	$is_gecko = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false) {
	$is_winIE = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
	$is_macIE = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
	$is_opera = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) {
	$is_NS4 = true;
}

if ( $is_safari && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') !== false )
	$is_iphone = true;

$is_IE = ( $is_macIE || $is_winIE );
	
	// exclude javascripts from being compressed automaticly
	if (isset($_GET['type']) && 'css' == $_GET['type']){
		$compress = true;
	}
	// set to false if you dont want to gzip cached it
	$cache = true;
	
	$cachedir = RT.'public'.DIRSEP.'cache';
	$cssdir = RT.'public'.DIRSEP.'css';
	$jsdir = RT.'public'.DIRSEP.'scripts';
	
	if (isset($_GET['files'])){
		$files = explode(',',$_GET['files']);
		
		if (is_array($files)){	
			$files = array_flip($files);
			
			if (isset($files['browser.css'])){
				unset($files['browser.css']);
				$files = array_flip($files);
				$files[] = 	wpi_is_browser().'.css';
				$_GET['files'] =implode(',',$files);	
			}			
		}
		
		unset($files);
	}
	
	require RT.'lib'.DIRSEP.'import'.DIRSEP.'combine.php';
	
} else {
	exit();
}


?>